`
https://leetcode.cn/problems/search-in-a-binary-search-tree/
`

/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} val
 * @return {TreeNode}
 */
var searchBST = function (root, val) {
  if (root === null) {
    return null;
  }
  // 去左子树搜索
  if (root.val > val) {
    return searchBST(root.left, val);
  }
  // 去右子树搜索
  if (root.val < val) {
    return searchBST(root.right, val);
  }
  // 目标值等于当前节点，直接返回
  return root;
};